package org.lql.algo.codecrush.week008;

import java.util.HashSet;
import java.util.Set;

/**
 * @author: liangqinglong
 * @date: 2025-08-19 00:02
 * @description: LCR 120. 寻找文件副本 <a href="https://leetcode.cn/problems/shu-zu-zhong-zhong-fu-de-shu-zi-lcof/description/">...</a>
 **/
public class FindRepeatDocument {

	public int findRepeatDocument(int[] documents) {
		Set<Integer> seen = new HashSet<>();
		for (int doc : documents) {
			if (seen.contains(doc)) {
				return doc;
			}
			seen.add(doc);
		}
		return -1;
	}

	public static void main(String[] args) {
		FindRepeatDocument findRepeatDocument = new FindRepeatDocument();
		System.out.println(findRepeatDocument.findRepeatDocument(new int[]{2, 3, 1, 0, 2, 5, 3}));
		System.out.println(findRepeatDocument.findRepeatDocument(new int[]{2, 4, 3, 5, 1}));
	}
}
